<template>
	<view class="body">	
		<view class="item"  v-for="i in scanlist">
			[{{i.page}}][{{i.date}}] {{i.code}}
		</view>
	</view>
</template>

<script>
	import SCan from 'common/scan.js'
	
	export default {
		data() {			
			return {
				scanlist:[]
			}
		},
		onShow: function(){ 			
		    SCan.initScan(this.saveCode)  
		    SCan.startScan();
			
			this.scanlist=this.$config.SysConfig.TODAY_SCAN;
		},  
		onHide:function(){  
		    SCan.stopScan();  
			this.scanlist=[];
		},  
		onUnload:function(){  
		    /*页面退出时一定要卸载监听,否则下次进来时会重复，造成扫一次出2个以上的结果*/  
		    SCan.stopScan();
			this.scanlist=[];
		},  
		
		methods: {		
			saveCode(code){
				//扫码记录日志
				var date=new Date();
				this.$config.SysConfig.TODAY_SCAN.push({
					page:'扫描',
					code:code,
					date:date.getHours()+':'+date.getMinutes()+":" +date.getSeconds()
				})
				this.scanlist=this.$config.SysConfig.TODAY_SCAN;
			}
		}
	}
</script>

<style>
.body{
	border-top: solid 1px #DBDBDA;
	padding: 0upx;
}
.item{
	padding: 5upx;
	line-height: 30upx;
}
/* ui,li{
	list-style:none;
	padding: 5upx 0upx;
} */
</style>
